package net.magicalcloud.magicalcloud.presenter;

import android.content.Intent;

import net.magicalcloud.magicalcloud.base.BasePresenter;
import net.magicalcloud.magicalcloud.entity.RestJson;
import net.magicalcloud.magicalcloud.entity.User;
import net.magicalcloud.magicalcloud.execption.CloudExecption;
import net.magicalcloud.magicalcloud.listener.CloudListener;
import net.magicalcloud.magicalcloud.model.IUserModel;
import net.magicalcloud.magicalcloud.model.modelImpl.UserModel;
import net.magicalcloud.magicalcloud.view.ILoginView;
import net.magicalcloud.magicalcloud.view.viewImpl.activity.MainActivity;

import retrofit2.Call;
import retrofit2.Callback;
import retrofit2.Response;

/** 用户presenter
 * Created by Pei on 2018/6/7.
 */

public class LoginPresenter extends BasePresenter<ILoginView>{

    private IUserModel model=new UserModel();

    /**
     * 验证用户登录
     */
    public void checkUser(String email,String passwd){
        model.findUserByEmail(email, passwd, new CloudListener<User>() {
            @Override
            public void done(User object, CloudExecption e) {
                if(e==null){
                    getView().loginResult(true);
                }else{
                    getView().loginResult(false);
                }
            }
        });
    }

}
